home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / POINTERS.SWG / 0024_Nth array item in BASM.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  519b  |  23 lines

  1. {
  2. CC> I want to know how to retrieve the n(th) element from the
  3. CC> table in BASM.
  4.  
  5. Solution:
  6. }
  7.  
  8.  program _getvalue;
  9.  
  10.  const table:array[0..9] of integer=
  11.    (1001,1002,1003,1004,1005,1006,1007,1008,1009,1010);
  12.  
  13.  function getvalue(nth:word):integer; assembler;
  14.  asm
  15.    mov si,nth                 { get index }
  16.    add si,si                  { 'multiply' by two (word-sized) }
  17.    mov ax,word ptr table[si]  { put table[index] in ax -> function-result }
  18.  end;
  19.  
  20.  begin
  21.    writeln(getvalue(7));
  22.  end.
  23.